#include "cuda_util.h"
#include "cush_alloc.h"

#include <cuda.h>
#include <stdio.h>

/**
 *
 * Combines the cush dbuff_t pointers and returns a new dbuff_t with the combined attributes
 * 
 * TODO: determine whether *dps should be a variable args list or an array
 *			It will be an array for now
 * TODO: Require a size check
 *
 **/
cush_dbuff_t* cush_combine_ptrs(cush_dbuff_t** dps, size_t ndevs){

	cush_dbuff_t* ret = (cush_dbuff_t*)malloc(sizeof(cush_dbuff_t));

	cush_dp_init(ret, dps[0]->type, ndevs);

	int i = 0;
	for(i = 0; i < ndevs; i++){
		ret->id[i] = dps[i]->id[0];
		ret->size[i] = dps[i]->size[0];
		ret->offset[i] = dps[i]->offset[0];
		ret->ptr[i] = dps[i]->ptr[0];

		//memcpy(&(ret->size[i]), dps[i]->size, sizeof(size_t));
		//memcpy(&(ret->offset[i]), dps[i]->offset, sizeof(size_t));
		//memcpy(&(ret->ptr[i]), dps[i]->ptr, sizeof(void**));
	}

	return ret;
}

